package bison;

class Position
{
   public var col:Int;
   public var line:Int;
   public var file:String;
   public static var count = 0;

   public function new(inLine:Int, inCol:Int, inFile:String)
   {
      line = inLine;
      col = inCol;
      file = inFile;
      count++;
   }

   public function toString():String
   {
      if (file!="")
         return file + "  Line:" + line + " Col:" + col;
      else
         return "Line:" + line + " Col : " + col;
   }

   public function rangeString(end:Position):String
   {
      var result = file;
      if (file!="") result+=" ";
      if (end==null || end.line==line)
      {
         result += "Line:" + line;
         if (end==null || end.col==col)
            result += " Col:" + col;
         else
            result += " Col:" + col + "-" + end.col;
      }
      else
         result += "Line:" + line + " Col:" + col + " - Line:" + end.line + " Col:" + end.col;

      return result;
   }



   public function equals(inRHS:Position)
   {
      if (inRHS==null)
          return true;
      return col==inRHS.col && line==inRHS.line && file==inRHS.file;
   }
}


